/*------------------------------------------------------------------------------
 * Copyright 2012 NCR Corporation
 *------------------------------------------------------------------------------
 * All revision information is updated automatically from source code control
 * change records - please do not manually edit.
 *------------------------------------------------------------------------------
 *
 *  $LastChangedRevision::                                          $
 *  $LastChangedBy::                                                $
 *  $LastChangedDate::                                              $
 */

package com.ncr.nep.dashboardcore.ui.client;

import com.google.gwt.user.client.ui.IsWidget;
import com.google.web.bindery.event.shared.Event;

/**
 * Event dispatched by the {@link DragManager} when a drag operation is
 * completed.
 * 
 * @author rb250096
 * @version $Revision$
 */
public class DragCompleteEvent extends Event<DragCompleteHandler> {

    /**
     * The event type.
     */
    public static final Type<DragCompleteHandler> TYPE =
            new Type<DragCompleteHandler>();

    /**
     * Widget that accepted the drop.  If no widget accepted the drop, this
     * will be null.
     */
    protected IsWidget acceptedTarget;

    /**
     * The widget being dragged around screen.
     */
    protected IsWidget dragSource;

    /**
     * Constructor
     *
     * @param dragSource The widget being dragged.
     * @param acceptedTarget The widget that accpted the drop.
     */
    public DragCompleteEvent(IsWidget dragSource, IsWidget acceptedTarget) {
        super();
        this.dragSource = dragSource;
        this.acceptedTarget = acceptedTarget;
    }

    @Override
    public Type<DragCompleteHandler> getAssociatedType() {
        return TYPE;
    }

    @Override
    protected void dispatch(DragCompleteHandler handler) {
        handler.onDragComplete(this);
    }

    /**
     * Gets the widget that accepted the drop.
     *
     * @return The widget that accepted the drop.
     */
    public IsWidget getAcceptedTarget() {
        return acceptedTarget;
    }

    /**
     * Gets the widget that is being dragged around screen.
     *
     * @return The widget that is being dragged around screen.
     */
    public IsWidget getDragSource() {
        return dragSource;
    }
}
